#pragma once
#include "cglobalcore_global.h"
#include <QObject>
#include <QVariantMap>
class CGLOBALCORE_EXPORT  ubNotificationCenter : public QObject
{
	Q_OBJECT
public:
	static ubNotificationCenter* defaultCenter(const char* identify = nullptr);
	void postNotification(const QString name = QString(), const QObject* sender = nullptr, QVariantMap userInfo = QVariantMap());
	void postNotification2(const QString name = QString(),  QObject* sender = nullptr , QVariantMap userInfo = QVariantMap() );
	int addObserver(QObject* receiver, const char* method, const QString& name = QString(), const QObject* sender = nullptr);
	int removeObserver(const QObject* receiver, const QString& name = QString(), const QObject* sender = nullptr);

	~ubNotificationCenter();
private:
	QMap<QString, QObject*> m_senderMap;
	ubNotificationCenter(QString name = QString(), QObject* parent = nullptr);
};

